package cn.dapeng.base;

import cn.dapeng.util.SleepingUtil;

import java.util.concurrent.TimeUnit;

public class WaitAndInterrupt {


    public static void main(String[] args) {
        Object monitor = new Object();
        Thread t1 = new Thread(() -> {
            try {
                synchronized (monitor) {
                    monitor.wait();
                }
            } catch (InterruptedException e) {
                System.out.println("thread interrupted");
                System.out.println(Thread.currentThread().isInterrupted());
            }
        });

        t1.start();
        SleepingUtil.sleep(1, TimeUnit.SECONDS);
        t1.interrupt();
    }
}
